﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="Mail_Setting.ascx.cs" Inherits="ERP.Modules.Mail_Setting" %>
<ext:Hidden ID="FormatTypeMail" runat="server" />
<%--------------GridMail-----------------%>
<ext:Panel ID="PanelMail" runat="server" Layout="Fit" Border="False">
    <Content>
        <ext:GridPanel
            ID="grMail"
            runat="server"
            Cls="grid-double"
            EnableColumnMove="true"
            Border="False">
            <Store>
                <ext:Store
                    ID="StoreMail"
                    runat="server"
                    OnReadData="StoreMail_RefreshData"
                    PageSize="20">
                    <Model>
                        <ext:Model runat="server" IDProperty="ID" GroupField="Email">
                            <Fields>
                                <ext:ModelField Name="ID" Type="Int" />
                                <ext:ModelField Name="Email" Type="String" />
                                <ext:ModelField Name="Passwords" Type="String" />
                                <ext:ModelField Name="Port" Type="Int" />
                                <ext:ModelField Name="Host" Type="String" />
                                <ext:ModelField Name="Content" Type="String" />
                                <ext:ModelField Name="Subjects" Type="String" />
                                <ext:ModelField Name="IsActive" Type="Boolean" />
                            </Fields>
                        </ext:Model>
                    </Model>
                </ext:Store>
            </Store>
            <ColumnModel runat="server">
                <Columns>
                    <ext:RowNumbererColumn Text="STT" runat="server" Width="30" Align="Center" />
                    <ext:Column runat="server" Text="Tài khoản" Width="100" DataIndex="Email"/>
                    <ext:Column runat="server" Text="Mật khẩu" Width="150" DataIndex="Passwords"/>
                    <ext:Column runat="server" Text="Cổng" Width="200" DataIndex="Port"/>
                    <ext:Column runat="server" Text="Máy chủ" Width="100" DataIndex="Host" Align="Left"/>
                    <ext:Column runat="server" Text="Tiêu đề" Width="150" DataIndex="Subjects"/>
                    <ext:Column runat="server" Text="Nội dung" Width="150" DataIndex="Content"/>
                    <ext:CheckColumn runat="server" Text="Trạng thái" DataIndex="IsActive" Align="Center" Flex="1"/>
                </Columns>
            </ColumnModel>
            <Features>
                <ext:Grouping
                    runat="server" 
                    HideGroupedHeader="true"
                    GroupByText="Xem theo phân nhóm"
                    ShowGroupsText="Phân nhóm"
                    GroupHeaderTplString="{name} ({rows.length} danh mục con {[values.rows.length > 1 ? '' : '']})"
                    StartCollapsed="True" />
            </Features>
            <DirectEvents>
                <ItemDblClick OnEvent="MailDblClick">
                    <ExtraParams>
                        <ext:Parameter Name="ID" Value="record.data.ID" Mode="Raw" />
                    </ExtraParams>
                    <EventMask ShowMask="true" Msg="Đang tải..." />
                </ItemDblClick>
            </DirectEvents>
            <SelectionModel>
                <ext:CheckboxSelectionModel runat="server" Mode="Multi">
                    <Listeners>
                        <SelectionChange Handler="
                            if (selected.length == 0) {
                                #{btnEdit}.disable();
                                #{btnDel}.disable();
                                #{btnExport}.disable();
                            } else {
                                #{btnEdit}.enable();
                                #{btnDel}.enable();
                                #{btnExport}.enable();
                            }" />
                    </Listeners>
                </ext:CheckboxSelectionModel>
            </SelectionModel>
            <View>
                <ext:GridView runat="server" StripeRows="true" />
            </View>
            <DockedItems>
                <ext:Toolbar runat="server" Dock="Top">
                    <Items>
                        <ext:Button ID="btnAddNew" runat="server" Text="Thêm mới" Icon="ApplicationAdd">
                            <DirectEvents>
                                <Click OnEvent="btnAddNew_Click">
                                    <EventMask ShowMask="true" Msg="Đang tải..." />
                                </Click>
                            </DirectEvents>
                        </ext:Button>
                        <ext:ToolbarSeparator />
                        <ext:Button ID="btnEdit" runat="server" Text="Sửa" Icon="ApplicationEdit">
                            <DirectEvents>
                                <Click OnEvent="btnEdit_Click">
                                    <EventMask ShowMask="true" Msg="Đang tải..." />
                                </Click>
                            </DirectEvents>
                        </ext:Button>
                        <ext:ToolbarSeparator />
                        <ext:Button ID="btnDel" runat="server" Text="Xoá" Icon="ApplicationDelete">
                            <DirectEvents>
                                <Click OnEvent="btnDel_Click">
                                    <EventMask ShowMask="true" Msg="Đang tải..." />
                                    <ExtraParams>
                                        <ext:Parameter Name="name" Value="btnDel"></ext:Parameter>
                                    </ExtraParams>
                                    <Confirmation ConfirmRequest="true"
                                        Title="Thông Báo" Message="Bạn có muốn xoá mẫu tin này không ?">
                                    </Confirmation>
                                </Click>
                            </DirectEvents>
                        </ext:Button>
                        <ext:ToolbarSeparator />
                        <ext:Button ID="btnExport" runat="server" Text="Xuất tập tin" Icon="Printer">
                            <Menu>
                                <ext:Menu ID="MenuMain" runat="server">
                                    <Items>
                                        <ext:MenuItem ID="MenuItemExportXML" runat="server" Text="XML" Icon="PageCode">
                                            <Listeners>
                                                <Click Handler="submitValue(#{grOrderServicesMaintain}, #{FormatTypeOrderServicesMaintain}, 'xml');" />
                                            </Listeners>
                                        </ext:MenuItem>
                                    </Items>
                                </ext:Menu>
                            </Menu>
                        </ext:Button>
                    </Items>
                </ext:Toolbar>
                <ext:Toolbar runat="server" Dock="Bottom" AnchorHorizontal="100%">
                    <Items>
                        <ext:TriggerField ID="txtSearch" runat="server" Width="200" EnableKeyEvents="true" MarginSpec="0 8 0 0">
                            <Triggers>
                                <ext:FieldTrigger Icon="Search" />
                            </Triggers>
                            <DirectEvents>
                                <TriggerClick OnEvent="Search_Event">
                                        <EventMask ShowMask="true" Msg="Đang tải..." />
                                </TriggerClick>
                                <SpecialKey OnEvent="Search_Event" Before="return e.getKey() == Ext.EventObject.ENTER;">
                                        <EventMask ShowMask="true" Msg="Đang tải..." />
                                </SpecialKey>
                            </DirectEvents>
                        </ext:TriggerField>
                        <ext:PagingToolbar runat="server" StoreID="StoreMail" BeforePageText="Trang" AfterPageText="của {0}" LastText="Cuối" NextText="Kế tiếp" PrevText="Trở lại" FirstText="Đầu" RefreshText="Làm tươi" DisplayInfo="true" DisplayMsg="Trang {0} - {1} của {2}" />
                    </Items>
                </ext:Toolbar>
            </DockedItems>
        </ext:GridPanel>
    </Content>
</ext:Panel>
<ext:Panel runat="server">
    <Content>
        <%-----------WindowsMail-----------------%>
        <ext:Window ID="WindowsMail" runat="server"
            Title="Cập nhật thông tin Mail"
            Width="572"
            Height="403"
            Hidden="True"
            Region="Center"
            Modal="True"
            DefaultAnchor="100%"
            HideMode="Display"
            Border="False"
            Padding="5"
            DefaultButton="btnSavePopUp"
            Resizable="False">
            <Items>
                <ext:Toolbar runat="server">
                    <Items>
                        <ext:Button runat="server" Text="Lưu lại" Icon="Disk" ID="btnSavePopUp">
                            <DirectEvents>
                                <Click OnEvent="btnSavePopUp_Click" Before="return #{FormPanelMail}.isValid();">
                                    <EventMask ShowMask="true" Msg="Đang tải..." />
                                </Click>
                            </DirectEvents>
                        </ext:Button>
                        <ext:ToolbarSeparator />
                        <ext:Button runat="server" Text="Huỷ bỏ" Icon="Decline" ID="btnCancelPopUp">
                            <DirectEvents>
                                <Click OnEvent="btnCancelPopUp_Click">
                                    <EventMask ShowMask="true" Msg="Đang tải..." />
                                </Click>
                            </DirectEvents>
                        </ext:Button>
                    </Items>
                </ext:Toolbar>
                <ext:FormPanel ID="FormPanelMail" runat="server"
                    AutoHeight="true"
                    BodyPadding="10"
                    Frame="true"
                    DefaultAnchor="100%">
                    <Items>
                        <ext:TextField ID="txtID" runat="server" FieldLabel="ID" LabelAlign="Right" Hidden="true" />
                        <ext:TextField ID="txtEmail" runat="server" FieldLabel="Tài khoản" AnchorHorizontal="100%" AllowBlank="false" />
                        <ext:TextField ID="txtPasswords" runat="server" FieldLabel="Mật khẩu" AnchorHorizontal="100%" AllowBlank="false" />
                        <ext:NumberField ID="txtPort" runat="server" FieldLabel="Cổng" AnchorHorizontal="100%" AllowBlank="false" Text="587" MinValue="0" />
                        <ext:TextField ID="txtHost" runat="server" FieldLabel="Máy chủ" AnchorHorizontal="100%" AllowBlank="false" Text="smtp.gmail.com" />
                        <ext:TextField ID="txtSubjects" runat="server" FieldLabel="Tiêu đề" AnchorHorizontal="100%" AllowBlank="false" />
                        <ext:Checkbox ID="chkIsActive" runat="server" FieldLabel="Sử dụng" AnchorHorizontal="100%" Checked="True" />
                        <ext:HtmlEditor ID="txtContent" runat="server" AnchorHorizontal="100%" Height="150"/>
                    </Items>
                </ext:FormPanel>
            </Items>
        </ext:Window>
    </Content>
</ext:Panel>